package com.jsgt.greekfire.ui.mine.user.messagelist.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.fhx.core.base.BaseAdapter
import com.fhx.core.base.BaseViewHolder
import com.fhx.core.utils.DateFormatUtil
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.MessageBean

/**
 * author fhx
 * create time 2020/4/22 20:27
 **/
class MessageAdapter : BaseAdapter<MessageBean>() {

    inner class VH(itemView: View) : BaseViewHolder(itemView) {
        private var title_tv: TextView? = null
        private var date_tv: TextView? = null

        init {
            title_tv = itemView.findViewById(R.id.title_tv)
            date_tv = itemView.findViewById(R.id.date_tv)
        }

        fun bindData(bean: MessageBean) {
            title_tv?.text = bean.title
            date_tv?.text = DateFormatUtil.formatNew(bean.createTime, "MM/dd HH:mm")
        }
    }

    override fun provideViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder? {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_message, parent, false)
        return VH(view)
    }

    override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
        val viewHolder = holder as VH
        viewHolder.bindData(dataList()[position])
    }
}